//
//  RegisterViewController.m
//  TinyFortune
//
//  Created by lc on 16/5/25.
//  Copyright © 2016年 lc. All rights reserved.
//

#import "RegisterViewController.h"
#import "verifyViewController.h"
#import "LCDelegateViewController.h"
@interface RegisterViewController ()<UITextFieldDelegate>

@end

@implementation RegisterViewController
- (void)cancel{
    [self.navigationController popViewControllerAnimated:YES];
     
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    //设置导航栏
    self.navigationController.navigationBar.translucent = NO ;
    [self.navigationController setNavigationBarHidden:NO];
    UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
    [self.navigationItem setLeftBarButtonItem:left];
    self.title = @"手机注册";
      [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:86/255.0f green:202/255.0f blue:255/255.0f alpha:0.5]];
    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [self.telText setKeyboardType:UIKeyboardTypePhonePad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)registerAction:(UIButton *)sender {
    //服务器表单加入该用户,并且添加所需要的字段
    AVUser *user = [AVUser user];
    user.mobilePhoneNumber = self.telText.text;//手机号码字段
    user.password = self.passwordText.text;//密码字段
    user.username = self.nameText.text;//用户名字段
    [user setObject:@"" forKey:@"sex"];//性别字段
    [user setObject:@"" forKey:@"signature"];//个性签名字段
    [user setObject:@"" forKey:@"area"];//位置字段
  
    [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        //短信验证用户信息
        if (succeeded) {
            verifyViewController *vertify = [verifyViewController new];
            vertify.telephoneNumber = self.telText.text;
            [self.navigationController pushViewController:vertify  animated:YES];
        }else{
            [KVNProgress showErrorWithStatus:error.localizedDescription];
            
        }
    }];
    
}

- (IBAction)tap1:(UITapGestureRecognizer *)sender {
    
    
    UIStoryboard * sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    LCDelegateViewController * delegateVC = [sb instantiateViewControllerWithIdentifier:@"LCDelegateViewController"];
    
    [self presentViewController:delegateVC animated:NO completion:^{
        
    }];
}


@end
